package gui;

import java.awt.*;
import java.awt.event.*;
import java.io.PrintStream;

// Referenced classes of package gui:
//            runGame

public class play
{

    public play()
    {
    }

    public static void main(String args[])
    {
        final runGame rg = new runGame();
        MenuBar mb = new MenuBar();
        Menu m0 = new Menu("Help");
        Menu m1 = new Menu("Options");
        final CheckboxMenuItem mi10 = new CheckboxMenuItem("Richman -> Poorman  ");
        final CheckboxMenuItem mi12 = new CheckboxMenuItem("Poorman -> Richman  ");
        final CheckboxMenuItem mi13 = new CheckboxMenuItem("Round Pass Rule");
        mi13.setState(true);
        mi10.setState(false);
        mi12.setState(false);
        MenuItem mi11 = new MenuItem("Reset");
        MenuItem mi1 = new MenuItem("How to Play?");
        MenuItem mi0 = new MenuItem("About");
        ActionListener al = new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {
                rg.about = true;
                rg.repaint();
            }

        };
        ItemListener rmpml = new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                rg.richpoor = mi10.getState();
                rg.repaint();
                if(rg.richpoor && rg.poorrich)
                {
                    mi12.setState(false);
                    rg.poorrich = false;
                }
            }

        };
        ItemListener pmrml = new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                rg.poorrich = mi12.getState();
                if(rg.richpoor && rg.poorrich)
                {
                    mi10.setState(false);
                    rg.richpoor = false;
                }
                System.out.println("Poorman/Richman set to:" + rg.poorrich);
                rg.repaint();
            }

        };
        ItemListener roundPassRule = new ItemListener() {

            public void itemStateChanged(ItemEvent e)
            {
                rg.roundPassRule = mi13.getState();
                System.out.println("Round Pass Rule Set To: " + rg.roundPassRule);
            }

        };
        ActionListener reset = new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {
                rg.wins0 = 0;
                rg.wins1 = 0;
                rg.wins2 = 0;
                rg.wins3 = 0;
                rg.resetScores();
                rg.repaint();
            }

        };
        mi11.addActionListener(reset);
        mi12.addItemListener(pmrml);
        mi10.addItemListener(rmpml);
        mi13.addItemListener(roundPassRule);
        mi0.addActionListener(al);
        m0.add(mi1);
        m0.add(mi0);
        mi1.setEnabled(false);
        m1.add(mi11);
        m1.add(mi10);
        m1.add(mi12);
        m1.add(mi13);
        mb.add(m1);
        mb.add(m0);
        rg.setMenuBar(mb);
    }
}
